#include <bits/stdc++.h>
// 2025/02/02
// tag: 
// Author: Zhang Muen
using namespace std;

int n, diff[4001][4001], square[1001][4];
set<int> discrete;
unordered_map<int, int> pos, pos2;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++){
        cin >> square[i][0] >> square[i][1] >> square[i][2] >> square[i][3];
        discrete.insert(square[i][0]), discrete.insert(square[i][1]);
        discrete.insert(square[i][2]), discrete.insert(square[i][3]);
    }
    for (auto it : discrete)
        pos[it] = ++cnt, pos2[cnt] = it;
    for (int i = 1; i <= n; i++)
        for (int j = pos[square[i][0]]; j < pos[square[i][2]]; j++)
            diff[j][pos[square[i][1]]]++, diff[j][pos[square[i][3]]]--;
    int64_t ans = 0;
    for (int i = 1; i < cnt; i++)
        for (int j = 1; j < cnt; j++)
            diff[i][j] += diff[i][j - 1];
    for (int i = 1; i < cnt; i++)
        for (int j = 1; j < cnt; j++)
            if (diff[i][j])
                ans += 1LL * (pos2[i + 1] - pos2[i]) * (pos2[j + 1] - pos2[j]);
    cout << ans << endl;
    return 0;
}